;#############################
;命令：
;nasm -f elf64 day0_2print_0printf.asm -o main.o && gcc main.o -o main -lc -no-pie && ./main
;输出：
;Hello, World! This is printf! Ye!1
;Hello, World! This is printf! Ye!1
;Hello, World! This is printf! Ye!3
;Hello, World! This is printf! Ye!4
;The int is 7
;The int is 20
;#############################
extern printf

section .data
	msg1: db "Hello, World! This is printf! Ye!1", 10, 0
	msg3: db "Hello, World! This is printf! Ye!3", `\n`, 0
	;请注意下面不是单引号'，而是反单引号`
	msg4: db `Hello, World! This is printf! Ye!4\n`, 0
	msg_num: db `The int is %d\n`, 0

section .text
	global main

main:
	push rbp
	mov rbp, rsp

;###############################################
	;为了在汇编语言中调用printf函数,
	;将第一个参数放在rdi寄存器中
	;将第二个参数放在rsi寄存器中
	;然后是rdx寄存器
	mov rdi, msg1
	call printf

	;确实有的人爱用这种形式
	;mov和lea的区别再单独讨论
	;load effective address
	lea rdi, [msg1]
	call printf

	mov rdi, msg3
	call printf

	mov rdi, msg4
	call printf

	mov rdi, msg_num
	mov rsi, 7
	call printf

	mov rdi, msg_num
	mov rsi, 20
	call printf

;###############################################

	mov eax, 0
	leave
	ret
